<template>

    <div>
        <BasicModal v-bind="$attrs" title="Modal Title" :helpMessage="['提示1', '提示2']" @register="registerModal"
            @ok="handleSubmit">
            Modal Info.
            Modal Info.
            {{ s }}

            <BasicForm @register="registerForm" />

        </BasicModal>
    </div>

</template>

<script setup lang="ts">
import { ref, computed, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { addFormSchema } from './customer.data';
import { list, saveOrUpdateUser } from './customer.api';

 // 声明Emits
 const emit = defineEmits(['success', 'register']);

 

let s = ref();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
    console.log(data);
    s.value = data;
});

//表单配置
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
    schemas: addFormSchema,
    showActionButtonGroup: false,
    labelWidth: '100px',
});


//表单提交事件
async function handleSubmit() {
    try {
      const values = await validate();
      setModalProps({ confirmLoading: true });
      //提交表单
      await saveOrUpdateUser(values);
      //关闭弹窗
      closeModal();
      //刷新列表
      emit('success');
    } finally {
      setModalProps({ confirmLoading: false });
    }
}
</script>

<style scoped></style>